<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let input = `0010101010110000101000010`

        console.log(input);

        let [l, r] = [0, 2]
        let res = []
        let tag = true


        for (let i = 1; i < input.length - 1; i++) {
            if (input[i] === '0' && input[r] == '0') {
                let test = input.slice(l, r)
                if (!test.includes('00') && !test.includes('11')) {
                    res.push(test)
                }
                l = r;
                i = l;
                r = l + 2;

            } else if (input[i] === '0' && input[r] == '1') {
                r++;
            } else if (input[i] === '1' && input[r] == '0') {

                if (r === input.length - 1) {
                    let test = input.slice(l, r+1)
                    if (!test.includes('00') && !test.includes('11')) {
                        res.push(test)
                    }
                    break;
                } else {
                    r++;
                }
            } else if (input[i] === '1' && input[r] == '1') {
                r++;
            }

        }
        if(res.length){
            console.log('0'+Math.max(...res));
        }else{
            console.log(-1);
            
        }
        

        



    </script>
</body>

</html>